from rest_framework.viewsets import ModelViewSet
from rest_framework.generics import ListAPIView
from apps.goods.models import SKU, SPU
from apps.contents.models import GoodsCategory
from apps.meiduo_admin.serializers.sku import SKUModelSerializer,CategoryModelSerializer, SPUSimpleModelSerializer
from apps.meiduo_admin.utils import PageNum


class SKUModelViewSet(ModelViewSet):
    queryset = SKU.objects.all()
    serializer_class = SKUModelSerializer
    pagination_class = PageNum


class ThreeCategoryListAPIView(ListAPIView):
    queryset = GoodsCategory.objects.filter(subs=None)
    serializer_class = CategoryModelSerializer


class SPUSimpleListAPIView(ListAPIView):
    queryset = SPU.objects.all()
    serializer_class = SPUSimpleModelSerializer